<template>
		<!--判断是否是标签节点-->
	<block v-if="node.node == 'element'">
		<!--button类型-->
		<button v-if="node.tag == 'button'" type="default" size="mini" :class="node.classStr" :style="node.styleStr">
			<wx-parse-template :node="node"  :avatarurl="avatarurl" :avatarurl2="avatarurl2" :nickname="nickname" :avatar="avatar" :buttontext="buttontext" :showbutton="showbutton" />
		</button>

		<!--a类型-->
		<view v-else-if="node.tag == 'a'" @click="wxParseATap(node.attr,$event)" :class="node.classStr" :data-href="node.attr.href" :style="node.styleStr" style="display: inline; border-bottom: 1px solid #555555;">
			<block v-for="(node, index) of node.nodes" :key="index">
				<wx-parse-template :node="node"  :avatarurl="avatarurl" :avatarurl2="avatarurl2" :nickname="nickname" :avatar="avatar" :buttontext="buttontext" :showbutton="showbutton" />
			</block>
		</view>

		<!--li类型-->
		<view v-else-if="node.tag == 'li'" :class="node.classStr" :style="node.styleStr">
			<block v-for="(node, index) of node.nodes" :key="index">
				<wx-parse-template :node="node"  :avatarurl="avatarurl" :avatarurl2="avatarurl2" :nickname="nickname" :avatar="avatar" :buttontext="buttontext" :showbutton="showbutton" />
			</block>
		</view>

		<!--table类型-->
		<wx-parse-table v-else-if="node.tag == 'table'" :class="node.classStr" :style="node.styleStr" :node="node"  :avatarurl="avatarurl"  :avatarurl2="avatarurl2"/>

		<!--br类型-->
		<!-- #ifndef H5 -->
			<text v-else-if="node.tag == 'br'">\n</text>
		<!-- #endif -->
		<!-- #ifdef H5 -->
			<br v-else-if="node.tag == 'br'">
		<!-- #endif -->

		<!--strong标签-->
		<view v-else-if="node.tag == 'strong'" :class="node.classStr" :style="node.styleStr" style="font-weight: 700;display: inline;">
			<block v-for="(node, index) of node.nodes" :key="index">
				<wx-parse-template :node="node"  :avatarurl="avatarurl" :avatarurl2="avatarurl2" :nickname="nickname" :avatar="avatar" :buttontext="buttontext" :showbutton="showbutton" />

			</block>
		</view>
		<!--span标签-->
		<view v-else-if="node.tag == 'span'" :class="node.classStr"  :style="node.styleStr" style="display: inline;">
			<block v-for="(node, index) of node.nodes" :key="index">
				<wx-parse-template :node="node"  :avatarurl="avatarurl" :avatarurl2="avatarurl2" :nickname="nickname" :avatar="avatar" :buttontext="buttontext" :showbutton="showbutton" />

			</block>
		</view>
		<!--em标签-->
		<view v-else-if="node.tag == 'em'" :class="node.classStr"  :style="node.styleStr" style="display: inline;font-style: italic;">
			<block v-for="(node, index) of node.nodes" :key="index">
				<wx-parse-template :node="node"  :avatarurl="avatarurl" :avatarurl2="avatarurl2" :nickname="nickname" :avatar="avatar" :buttontext="buttontext" :showbutton="showbutton" />
			</block>
		</view>

		<!--video类型-->
		<wx-parse-video :node="node"  :avatarurl="avatarurl" :avatarurl2="avatarurl2" v-else-if="node.tag == 'video'"/>

		<!--audio类型-->
		<wx-parse-audio :node="node"  :avatarurl="avatarurl" :avatarurl2="avatarurl2" v-else-if="node.tag == 'audio'"/>

		<!--img类型-->
		<wx-parse-img :node="node"  :avatarurl="avatarurl"  :avatarurl2="avatarurl2" v-else-if="node.tag == 'img'" :style="node.styleStr"/>

		<!--其他标签-->
		<view v-else :class="node.classStr" :style="node.styleStr">
			<block v-for="(node, index) of node.nodes" :key="index">
				<wx-parse-template :node="node"  :avatarurl="avatarurl" :avatarurl2="avatarurl2" :nickname="nickname" :avatar="avatar" :buttontext="buttontext" :showbutton="showbutton" />
				
			</block>
		</view>
	</block>
  <!--判断是否是文本节点-->
	<!--判断是否是文本节点-->
	  <block v-else-if="node.node == 'text'">
	    <view v-if="node.text == '#@nickname@#'">
			<view class="nicknameinfo">
			   {{nickname}}
			</view>
			<button type="primary" @tap="getUserInfo" style="bottom: 12px;position: absolute;width: 80%;left:10%; height: 35px;margin-left:auto;margin-right:auto"  v-if="showbutton == '1'">
			<div class="shareview" >			{{buttontext}}</div>

			
			</button>
					
	    </view>
	    <view v-else-if="node.text == '#@nickavatar@#'" class="userinfo">
		  <image class='avatarpic' :src='avatarurl'></image>
	      <view class="userinfo-avatar">       
	        <open-data  type="userAvatarUrl"></open-data>
	      </view>
	    </view>
	    <view v-else-if="node.text == '#@nickavatar2@#'" class="userinfo">
			<image class='avatarpic' :src='avatarurl2'></image>
	      <view class="userinfo-avatar">
	        
	        <open-data  type="userAvatarUrl"></open-data>
	
	      </view>
	    </view>
	    <view v-else>
	      {{node.text}}
	    </view>
	  </block>
	</template>
	

<script>
	import wxParseTemplate from './wxParseTemplate4';
	import wxParseImg from './wxParseImg';
	import wxParseVideo from './wxParseVideo';
	import wxParseAudio from './wxParseAudio';
	import wxParseTable from './wxParseTable';
	
	export default {
		name: 'wxParseTemplate3',
		props: {
			node: {},avatarurl:{},avatarurl2:{},nickname:'' ,avatar:'', buttontext:'',	  showbutton:'',
		},
		components: {
			wxParseTemplate,
			wxParseImg,
			wxParseVideo,
			wxParseAudio,
			wxParseTable
		},
		methods: {
			wxParseATap(attr,e) {
				const {
					href
				} = e.currentTarget.dataset;
				if (!href) return;
				let parent = this.$parent;
				while(!parent.preview || typeof parent.preview !== 'function') {
					parent = parent.$parent;
				}
				parent.navigate(href, e, attr);
			},
		  getUserInfo(){
			  this.$emit('getUserInfo');
		  }
		}
	};
</script>
<style>
.userinfo-avatar {
  overflow:hidden;
  display: block;
  width: 160rpx;
  height: 160rpx;

  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.2);
  margin:auto;
}
.userinfo {
  color: #fff;



}

.avatarpic{
  margin:auto;
  width: 180px;
  height: 180px;
  position: relative;
  margin-bottom: -160px;
}
.nicknameinfo{
	margin-top:90px;
}
  .shareview{

    display: flex;
    align-items: center;
    text-align: center;
    justify-content: center;
	height: 35px;
  }


</style>